#pragma once
#include <iostream>
#include <string>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>

class INetAddr
{
public:
    void GetAddress()
    {
        _port = ntohs(_local.sin_port);
        _ip = inet_ntoa(_local.sin_addr);
    }
public:
    INetAddr(const struct sockaddr_in& s)
        :_local(s)
    {
        GetAddress();
    }
    std::string IP()
    {
        return _ip;
    }
    uint16_t Port()
    {
        return _port;
    }
    ~INetAddr()
    {}
private:
    struct sockaddr_in _local;
    std::string _ip;
    uint16_t _port;
};